﻿using System;
using System.Linq;
using System.Windows.Data;

namespace SoftSource.Timecard.Converters
{
    public class ProjectIDToCategorySummaryConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is int)
            {
                int id = (int)value;

                var categories = App.Model.ProjectCategorySummaries.Entities
                    .Where(pc => pc.ProjectID == id)
                    .Select(pc => pc.CategorySummary);

                return categories;
            }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
